﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace ConsoleApp10
{
    public class OrderDetails
    {
        public List<Goods> goods;
        public List<int> num;
        public Goods this[int num] { get => goods[num];  }
        public OrderDetails()
        {
            goods = new List<Goods>();
            num = new List<int>();
        }
        public void Add(Goods g,int n)
        {
            goods.Add(g);
            num.Add(n);
            Console.WriteLine("商品添加成功");
        }
        public override bool Equals(object obj)
        {
            OrderDetails m = obj as OrderDetails;
            return m != null && m.goods == goods && m.num == num;
        }
        public override string ToString()
        {
            string str = "订单中商品有：\n";
            for(int i=0;i< goods.Count; i++)
            {
                str = str + goods[i].ToString() + "  数量：" + num[i] + "\n";
            }
            return str;
        }
    }
    public class Goods
    {
        private string name;
        private int price;
        public int Price { get => price; }
        public string Name { get => name; }
        public Goods(string str,int num)
        {
            name = str;
            price = num;
        }
        public override string ToString()
        {
            return name + "  单价：" + price;
        }
    }
}
